<?php

use yii\captcha\Captcha;
use yii\widgets\ActiveForm;

?>
<div class="content">
    <div class="main">
        <div class="banner">
            <img src="./images/banner.png">
        </div>
        <div class="form-cx">
            <ul>
                <li class="active">期货</li>
                <li>原油</li>
                <li>交易所</li>
                <li>贵金属</li>
                <li>现货</li>
                <li>外汇</li>
            </ul>
            <div class="inner_block4">
                <span><img src="./images/sousuo.png"></span>
                <input type="text" class="b_input" placeholder="请输入平台或公司名称">
                <span class="b_btn">查询</span>
            </div>
            <p class="num">已为<i>16092</i>名网友认证平台<i>131303</i>次</p>
            <p class="ptjg">拥有全国最大数据库，已收入<i>32503</i>家平台机构</p>
        </div>
    </div>
</div>
<div class="footer">
    <p>大交所环渤海第578号会员单位</p>
    <p>版权所有&nbsp;&nbsp;&nbsp;&nbsp;上海犇璟商务咨询有限公司</p>
</div>
<!-- pop -->
<div class="pop">
    <div class="inner_pop">
        <div class="pop_p1">云数据连接中......</div>
        <div class="pop_p2">咨询关于期货的所有问题</div>
        <div class="pop_input hd_name_bar">
            <span>平台名称：</span>
            <input type="text" placeholder="请输入查询的平台" class="hd_name">
        </div>
        <div class="pop_input">
            <span>姓名：</span>
            <input type="text" placeholder="请输入您的姓名" class="user_name">
        </div>
        <div class="pop_input">
            <span>手机：</span>
            <input type="text" placeholder="请输入您的手机号" class="user_tell">
        </div>
        <div class="pop_input">
            <span>验证码：</span>
            <input type="text" placeholder="请输入验证码" class="code" style='width: 110px'>
            <button class="getCode" id="updateverify">获取验证码</button>
        </div>
        <div class="pop_btn">提交</div>
    </div>
    <span class="pop_close"></span>
</div>

<script type="text/javascript">
    $(function(){
        $(".form-cx li").click(function(){
            $(this).addClass("active").siblings().removeClass("active");
        });
        //样式
        $('.pop_input>input').focus(function(){
            $(this).css('border-color','red');
        })
        $('.pop_input>input').blur(function(){
            $('.pop_input>input').css('border-color','#bfbfbf');
        })

        // 关闭弹窗
        $('.pop_close').click(function(){
            $('.hd_name_bar').removeClass('hd_name_hide');
            $('.b_input').val('');
            pop_hide();
        })

        // 循环
        $('.banner_data_R>ul>li').clone().appendTo('.banner_data_R>ul');
        var timer = null;
        var num = 0;
        var run_height = $('.banner_data_R>ul').outerHeight();
        timer = setInterval(function(){
            num -=2;
            if(num <= - run_height/2){
                num = 0;
            }
            $('.banner_data_R>ul').css('top',num);
        },100)

        // pop
        var question_val = '';
        $('.b_btn').click(function(){
            question_val = $(this).siblings('.b_input').val();
            if(question_val == ''  ){
                alert('请输入您要查询的名称/代码或咨询的问题');
            }else{
                $(".hd_name").val(question_val);
                setCookie('question_val',question_val,30);
                $('.hd_name_bar').addClass('hd_name_hide');
                pop_show();

            }
        })
        //console.log(getCookie('company_val'));



        $('.hd_name').blur(function(){
            question_val = $('.hd_name').val();
            setCookie('question_val',question_val,30);
        })

        $('.user_name').blur(function(){
            var user_name_val = $('.user_name').val();
            setCookie('user_name',user_name_val,30);
        })

        $('.user_tell').blur(function(){
            var tel_num = $('.user_tell').val();
            var reg = /^0{0,1}(13[0-9]|14[0-9]|15[0-9]|18[0-9]|17[0-9])[0-9]{8}$/i;
            if(tel_num == '' && tel_num == null){
                alert('请输入您的手机号码');
            }else if(!reg.test(tel_num)){
                alert('您的手机号码不正确哦，请重新输入');
                $('.user_tell').val('');
            }
            setCookie('user_tel',tel_num,30);
        })

        var serch_w = '';
        var keyword_w = '';
        var SubmitFlag = true;
        var GetCodeFlag = true;
        var source = window.location.href;//获取URL地址

        // 短信验证码
        $(".getCode").click(function(){
            var user_tell_val = $('.user_tell').val();
            if(GetCodeFlag){
                if(!user_tell_val){
                    alert('请输入手机号码');
                    return false;
                }else{
                    GetCodeFlag = false;
                    var url = "/site/sendsms";
                    $.ajax({
                        url:url,
                        type:'post',
                        data:{'mobile': user_tell_val},
                        dataType:'json',
                        success:function(data) {
                            if(data.success == "发送成功"){
                                setTime();
                                alert('短信发送成功');
                            }else{
                                GetCodeFlag = true;
                                alert(data.message);
                            }
                        }
                    })

                }
            }

        })
        // 倒计时
        var wait=60;
        function setTime(){
            var e = $(".getCode");
            if(wait == 0){
                GetCodeFlag = true;
                e.removeClass("crc");
                e.css("cursor", "");
                e.text("发送验证码");
                wait = 60;
            }else{
                // e.addClass("disabled");
                e.addClass("crc");
                e.css("cursor", "pointer");
                e.text(wait+"秒后重新获取");
                wait--;
                setTimeout(function(){
                    setTime();
                },1000);
            }
        }
        // 提交
        $('.pop_btn').click(function(){
            if(!$('.hd_name_bar').hasClass('hd_name_hide')){
                question_val = $('.hd_name').val();
            }
            console.log(question_val );
            var user_name_val = $('.user_name').val();
            var user_tell_val = $('.user_tell').val();
            var tel_code_val = $('.tel_code').val();
            var code = $(".code").val();
            if(SubmitFlag){
                if(!$('.hd_name_bar').hasClass('hd_name_hide') && question_val == ''){
                    alert('请输入项目名称');
                    return false;
                }else if(user_name_val == ''){
                    alert('请输入姓名');
                    return false;
                }else if(code == " "){
                    alert('请输入您的验证码');
                    return false;
                }else if(user_tell_val == ''){
                    alert('请输入手机号码');
                    return false;
                }else{
                    SubmitFlag = false;
                    $.ajax({
                        type:'post',
                        url:'/site/siginup',
                        dataType:'json',
                        data:{
                            beizhu:question_val,
                            nick_name:user_name_val,
                            mobile:user_tell_val,
                            referer:source,
                            sms_code:code
                            // 'search':serch_w ,
                            // 'keyword':keyword_w
                        },
                        success:function(res){
                            // console.log(response);
                            SubmitFlag = true;
                            if(res.code == 1){
                                alert('提交成功，\n稍后会有专业顾问致电您做更详尽的解答, 请保持手机畅通！');
                                pop_hide();
                                $('.b_input').val('');
                                $('.user_name').val('');
                                $('.user_tell').val('');
                                $('.hd_name').val();
                            }else{
                                SubmitFlag = true;
                                for (var i in res.data){
                                    layer.msg(res.data[i][0]);
                                    break;
                                }

                                $("form .btn-get").attr("onclick", "getCode(this)");
                                $("form .btn-get").removeClass("btn-disabled");
                                return false;
                            }
                            // if(msg.msg=='手机号码已经存在'){
                            //     alert('信息已经成功提交，请勿重复提交');
                            // }else if(msg.msg=='提交成功'){
                            // 	alert('提交成功，\n稍后会有专业顾问致电您做更详尽的解答，电话号码为170018350** 请保持手机畅通！');
                            // 	pop_hide();
                            // 	$('.b_input').val('');
                            // }

                        }
                    })
                }
            }



        })


        $('.section_block2_li_btn').click(function(){
            $('.hd_name_bar').removeClass('hd_name_hide');
            pop_show();
        })


    })

    function pop_show(){
        $('.pop').show().animate({'height':'350px','margin-top':'-160px'},200);
    }
    function pop_hide(){
        $('.pop').css({'height':'0px','margin-top':'-0px'}).hide();
    }

    function setCookie(name,value)
    {
        var Days = 30;
        var exp = new Date();
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
    }


    //读取cookies
    function getCookie(name)
    {
        var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg))
            return (arr[2]);
        else
            return null;
    }

    //删除cookies
    function delCookie(name)
    {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval=getCookie(name);
        if(cval!=null)
            document.cookie= name + "="+cval+";expires="+exp.toGMTString();
    }
</script>

